package com.lhy.service;

import com.lhy.entity.User;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Author：罗昊宇
 * @Package：com.lhy.service
 * @Project：shiro-framwork
 * @name：UserService
 * @Date：2024/5/8 0008  19:38
 * @Filename：UserService
 */
public class UserService {

    public User selectByName(String username){
        User user =null;
        switch (username){
            case "admin":
                user=new User(1,"admin","123456","管理员");
                break;
            case "ldh":
                user=new User(2,"ldh","91e50df63f9435d3a8e115987dd62a5a","刘德华");
                break;
            default:
                user=new User(3,"lhy","123","罗昊宇");
                break;
        }
        return user;
    }
    //根据用户名查询该用户具有的权限
    public List<String> selectPermissionByName(String username) {
        List<String> list = new ArrayList<>();
        switch (username) {
            case "admin":
                Collections.addAll(list,"user:query","user:delete","user:update","user:insert");
                break;
            case "lhy":
                Collections.addAll(list,"user:query","user:export");
                break;
            default:
                Collections.addAll(list,"user:delete","user:update");
        }
        return list;
    }
}
